package com.easy.controller;


import com.easy.bean.AdoptBean;
import com.easy.bean.AdoptBookingBean;
import com.easy.service.AdoptBookingService;
import com.easy.util.Page;
import com.easy.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("adoptBooking")
public class AdoptBookingController {

    @Autowired
    AdoptBookingService adoptBookingService;

    @PostMapping
    public Result add(@RequestBody AdoptBookingBean adoptBookingBean){
        Object obj=adoptBookingService.add(adoptBookingBean);
        return Result.success(obj);
    }

    @DeleteMapping("{id}")
    public Result del(@PathVariable("id") Integer id){
        int obj=adoptBookingService.del(id);
        return Result.success(obj);
    }

    @PutMapping
    public Result edit(@RequestBody AdoptBookingBean adoptBookingBean){
        Object obj=adoptBookingService.edit(adoptBookingBean);
        return Result.success(obj);
    }

    @GetMapping("all")
    public Result all(AdoptBookingBean adoptBookingBean){
        Object obj=adoptBookingService.all(adoptBookingBean);
        return Result.success(obj);
    }

    @GetMapping("{id}")
    public Result one(@PathVariable("id") Integer id){
        Object obj=adoptBookingService.one(id);
        return Result.success(obj);
    }

    @GetMapping("page")
    public Result page(Page page, AdoptBookingBean adoptBookingBean){
        //查询一共有多少数据
        //查询当前页要显示的数据
        //将以上数据封装到page对象中
        adoptBookingService.page(page,adoptBookingBean);
        //返回page对象
        return Result.success(page);
    }

}






















